import request from '@/router/axios'

export function addIndex(indexName, obj, indexId) {
    return request({
        url: '/river/' + indexName,
        method: 'post',
        params: {
            indexId
        },
        data: obj
    })
}

export function setIndex(indexName, obj, indexId) {
    if(obj.id === null || obj.id === "") {
        return addIndex(indexName, obj, indexId)
    } else {
        return updateIndex(indexName, obj, indexId) 
    }
}

export function updateIndex(indexName, obj, indexId) {
    return request({
        url: '/river/' + indexName,
        method: 'put',
        params: {
            indexId
        },
        data: obj
    })
}

export function getIndex(indexName, riverId, fillType) {
    return request({
        url: '/river/' + indexName,
        method: 'get',
        params: {
            riverId,
            fillType
        }
    })
}

export function delFile(indexName, indexId, fileName) {
    return request({
        url: '/river/' + indexName + "/delfile/" + indexId,
        method: 'put',
        params: {
            fileName
        }
    })
}

export function getExpertFillList(indexName, riverId) {
    return request({
        url: '/river/' + indexName + "/expert/list",
        method: 'get',
        params: {
            riverId
        }
    })
}